﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Joel.Net;

namespace myMvcBlog.Services
{
    public class SpamCommentService
    {
        const string apiKey = "4907e11cd6f8";
        const string blog = "http://www.jun1stfeng.com";

        static Akismet akiService = new Akismet(apiKey, blog, null);

        public static bool CheckComment(Comment comment)
        {
            AkismetComment comm = new AkismetComment();
            comm.Blog = "http://www.jun1stfeng.com";
            comm.UserIp = comment.IP;
            comm.UserAgent = "";
            comm.CommentContent = comment.Content;
            comm.CommentType = "blog";
            comm.CommentAuthor = comment.Author;
            comm.CommentAuthorEmail = comment.Email;
            comm.CommentAuthorUrl = comment.Site;

            try
            {
                return akiService.CommentCheck(comm);
            }
            catch
            {
                return true;
            }
        }
    }
}